package com.ruoyi.web.controller.video;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.videos.domain.MyShortVideo;
import com.ruoyi.videos.service.IMyShortVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 短视频列表Controller
 * 
 * @author zunzun
 * @date 2023-11-29
 */
@RestController
@RequestMapping("/videos/videos")
public class MyShortVideoController extends BaseController
{
    @Autowired
    private IMyShortVideoService myShortVideoService;

    /**
     * 查询短视频列表列表
     */
    @PreAuthorize("@ss.hasPermi('videos:videos:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyShortVideo myShortVideo)
    {
        startPage();
        List<MyShortVideo> list = myShortVideoService.selectMyShortVideoList(myShortVideo);
        return getDataTable(list);
    }

    /**
     * 导出短视频列表列表
     */
    @PreAuthorize("@ss.hasPermi('videos:videos:export')")
    @Log(title = "短视频列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MyShortVideo myShortVideo)
    {
        List<MyShortVideo> list = myShortVideoService.selectMyShortVideoList(myShortVideo);
        ExcelUtil<MyShortVideo> util = new ExcelUtil<MyShortVideo>(MyShortVideo.class);
        util.exportExcel(response, list, "短视频列表数据");
    }

    /**
     * 获取短视频列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('videos:videos:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(myShortVideoService.selectMyShortVideoById(id));
    }

    /**
     * 新增短视频列表
     */
    @PreAuthorize("@ss.hasPermi('videos:videos:add')")
    @Log(title = "短视频列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyShortVideo myShortVideo)
    {
        return toAjax(myShortVideoService.insertMyShortVideo(myShortVideo));
    }

    /**
     * 修改短视频列表
     */
    @PreAuthorize("@ss.hasPermi('videos:videos:edit')")
    @Log(title = "短视频列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyShortVideo myShortVideo)
    {
        return toAjax(myShortVideoService.updateMyShortVideo(myShortVideo));
    }

    /**
     * 删除短视频列表
     */
    @PreAuthorize("@ss.hasPermi('videos:videos:remove')")
    @Log(title = "短视频列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(myShortVideoService.deleteMyShortVideoByIds(ids));
    }
}
